<?php

namespace App\Kuafu\User\Validate;

use App\Exceptions\CustomValidateException;
use App\Http\Validate\AbstractBaseValidate;
use Illuminate\Support\MessageBag;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class CacheValidate extends AbstractBaseValidate
{

    /**
     * @inheritDoc
     */
    function getRules(): array
    {
        // TODO: Implement getRules() method.
        return [
            "cacheKeys"   => "required|array|min:1",
            "cacheKeys.*" => "string|min:1|max:120"
        ];
    }

    /**
     * @inheritDoc
     */
    function getAttributes(): array
    {
        // TODO: Implement getAttributes() method.
        return [
            "cacheKey" => "缓存key"
        ];
    }

    /**
     * @inheritDoc
     */
    function registerValidateRules(): void
    {
        // TODO: Implement registerValidateRules() method.
    }

    /**
     * @inheritDoc
     */
    function getMessages(): array
    {
        // TODO: Implement getMessages() method.
        return [];
    }

    /**
     * 移除缓存校验
     *
     * @param array $params
     * @return MessageBag|object
     * @throws CustomValidateException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function rmCacheKeyValidate(array $params)
    {
        return self::getInstance()->validate(["cacheKeys"], $params);
    }
}
